#ifndef __PROTOCOL_DETECTOR_H__
#define __PROTOCOL_DETECTOR_H__

#include <memory>
#include <deque>
#include <session.h>
#include <base_protocol.h>

namespace secsmart_protocol
{
    enum DETECT_STATE { 
        DETECT_STATE_INIT,
        DETECT_STATE_SUCCESS,
        DETECT_STATE_UNKNOW
    };

    class ProtocolDetector{
    public:
        ProtocolDetector(std::string& targetFileName, uint32_t matchCount);
        ~ProtocolDetector();
        void dissector(secsmart_session::session_sptr session, const uint8_t *buf, size_t size, bool is_forward);
    private:
        void init();
        void writeFile(std::shared_ptr<secsmart_protocol::BaseProtocol> protocol);

    private:
        std::deque<std::shared_ptr<secsmart_protocol::BaseProtocol>> protocolLike;
        std::string outFileName; //输出的文件名
        uint32_t maxMatchCount = 0;//最大的匹配数据包个数:当达到这个量时就认为已匹配上
        DETECT_STATE detectState = DETECT_STATE::DETECT_STATE_INIT;

    };
};

#endif